package com.yuyu.service.impl;

import com.yuyu.bean.OrderItem;
import com.yuyu.service.OrderItemService;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.ArrayList;
import java.util.List;

import static org.junit.jupiter.api.Assertions.*;

class OrderItemServiceImplTest {
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
    OrderItemService orderItemService = (OrderItemService) applicationContext.getBean("orderItemService");

    @Test
    void findOrderItemWithOrderId() {
        List<OrderItem> orderItems = orderItemService.findOrderItemWithOrderId(1);
        System.out.println(orderItems);
    }

    @Test
    void addOrderItem() {
        OrderItem orderItem = new OrderItem();
        orderItem.setId(1);
        orderItem.setOrder_id(1);
        orderItem.setAmount(11);
        orderItem.setPrice(50.0);
        orderItem.setProduct_id(2);
        System.out.println(orderItemService.addOrderItem(orderItem));
    }

    @Test
    void deleteOrderItemById() {
        List<Integer> list = new ArrayList<>();
        list.add(1);
        System.out.println(orderItemService.deleteOrderItemById(list));
    }

    @Test
    void editOrderItem() {
        OrderItem orderItem = new OrderItem();
        orderItem.setId(1);
        orderItem.setOrder_id(12);
        orderItem.setAmount(12);
        orderItem.setPrice(12.0);
//        orderItem.setProduct_id(12);
        System.out.println(orderItemService.editOrderItem(orderItem));
    }
}